package com.bike.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bike.entity.HhFoodLib;
import com.bike.mapper.HhFoodLibMapper;
import com.bike.util.PageData;
import com.bike.util.TransFerUtil;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

@Service
public class HhFoodLibServiceImpl extends BaseServcieImpl  {

	@Autowired
	HhFoodLibMapper hhFoodLibMapper;
	
	/**
	* 保存
	*/
	public void saveOrUpdate(PageData pd, HhFoodLib record) {
		if(pd.getLong("foodLibId")>0){
			 //编辑
			hhFoodLibMapper.updateByPrimaryKeySelective(record);
		}else{
			hhFoodLibMapper.insertSelective(record);
		}
	}
	
	/**
	* 删除
	*/
	public int deleteHhFoodLibById(long foodLibId) {
		return hhFoodLibMapper.deleteByPrimaryKey(foodLibId);
	}
	
	/**
	*列表分页
	*/
	public PageData selectHhFoodLibList(PageData pd) {
		PageData result=new PageData();
		PageBounds pageBounds=(PageBounds) pd.get("pageB");
		 
		List<HhFoodLib> records= hhFoodLibMapper.selectByPage(pd,pageBounds);
		result.put("rows",records );
		result.put("total", ((PageList<HhFoodLib>) records).getPaginator().getTotalCount());
		return result;
	}
	 
	/**
	*列表(全部)
	*/
	public List<HhFoodLib> listAll(PageData pd) {
		return  hhFoodLibMapper.selectAll(pd);
	}
	
	/**
	* 通过id获取数据
	*/
	public HhFoodLib selectByHhFoodLibId(Long foodLibId) {
		return hhFoodLibMapper.selectByPrimaryKey(foodLibId);
	}
}

